package org.study.meilisearch.boot.config;

import com.meilisearch.sdk.Client;
import com.meilisearch.sdk.Config;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Meilisearch配置类
 *
 * @author doveylovey
 * @version v1.0.0
 * @email 1135782208@qq.com
 * @date 2025年04月27日
 */
@Configuration
@EnableConfigurationProperties(value = {MeilisearchProperties.class})
public class MeilisearchConfig {
    @Bean
    public Client searchClient(MeilisearchProperties meilisearchProperties) {
        String hostUrl = meilisearchProperties.getHostUrl();
        String apiKey = meilisearchProperties.getApiKey();
        Config config = new Config(hostUrl, apiKey);
        Client client = new Client(config);
        return client;
    }
}
